﻿using System;
/*Write a program that finds the maximal increasing sequence in an array. Example: {3, 2, 3, 4, 2, 2, 4}
 *  {2, 3, 4}. */


    class MaximalIncreasingSequence
    {
        static void Main()
        {
            int[] array = {4,6,1,2,5,6,7};

            int maxLenght = 1;
            int currLenght = 1;
            int firstElement = 0;

            for (int i = 0; i < array.Length - 1; i++)
            {
                if (array[i] < array[i + 1])
                {
                    currLenght++;
                    if (currLenght > maxLenght)
                    {
                        maxLenght = currLenght;
                        firstElement = (i - currLenght)+2;
                    }
                    
                }
                else
                {
                    currLenght = 1;
                }
                
            }
            for (int i = firstElement; i < firstElement+maxLenght ; i++)
            {
                Console.WriteLine("{0}", array[i]);
            }
            Console.WriteLine("The max lenght is:");
            Console.WriteLine(maxLenght);
            Console.WriteLine("The first index of the sequence is:");
            Console.WriteLine(firstElement);
           
        }
    }

